Hitherto, in an electronic control unit (hereinbelow, called ECU) for controlling components in a vehicle, when a fault is detected in a predetermined object to be detected, according to the law, a diagnostic trouble code indicative of the fault is configured to be stored in a semiconductor memory (such as SRAM, EEPROM, or the like). An SRAM is also called as a backup RAM and is a volatile memory to which voltage is always supplied from a battery of a vehicle. An EEPROM is a nonvolatile memory.
According to the law, after a diagnostic trouble code is stored in a volatile memory (for example, in the SRAM), by the end of an ignition cycle (a period between turn-on of an ignition switch of the vehicle and the next turn-off, or between turn-off of the ignition switch and the next turn-on), the same code as the diagnostic trouble code has to be stored in the nonvolatile memory (for example, in the EEPROM).
It is expected that the law is determined in consideration of the fact that a diagnostic trouble code stored in the volatile memory is illegally deleted or a diagnostic trouble code disappears for some reason. For example, when the battery of a vehicle is removed and voltage is not supplied to the volatile memory, or when abnormality occurs in the volatile memory and the volatile memory is initialized, a diagnostic trouble code stored in the volatile memory code disappears. However, the diagnostic trouble code stored in the nonvolatile memory can be read. The diagnostic trouble codes stored in the volatile memory and the nonvolatile memory are used for analyzing a fault. For example, when a person in charge in a factory connects a fault diagnosis apparatus to the ECU communicatively and requests the ECU for a diagnostic trouble code via the fault diagnosis apparatus, the ECU reads a diagnostic trouble code from the volatile memory or the nonvolatile memory and sends it to the fault diagnosis apparatus. The fault diagnosis apparatus analyzes the location, the cause, and the like of the fault in the vehicle on the basis of the diagnostic trouble code.
A technique of assuring the reliability of data stored in the volatile memory and the nonvolatile memory is disclosed in, for example, a patent document JP-A-2004-21520.
In the patent document JP-A-2004-21520, a volatile memory has a first storage area for storing data to be stored and a second storage area for storing the same data as the data to be stored, and a nonvolatile memory has a third storage area for storing the same data as the data to be stored. The ECU compares the data in the first storage area, the data in the second storage area, and the data in the third storage area and employs as correct data) the data matched in the two or more areas. In such a manner, reliability is assured.
The precondition of the technique of the above patent document is that all of data in the first storage area in the volatile memory is stored in the second storage area in the volatile memory and the third storage area in the nonvolatile memory. However, a case is expected such that data in the volatile memory is deleted due to removal of the battery or an erasure instruction from an external tool. In this case, in the above patent document, the data in the volatile memory and the data in the nonvolatile memory become inconsistent, and it is concerned that the data in the nonvolatile memory, which should not be rewritten, is erroneously rewritten.